home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / lang / fpc09905c.lha / fpc / inc / systemh.inc < prev    next >
Text File  |  1998-09-21  |  18KB  |  509 lines

  1. {
  2.     $Id: systemh.inc,v 1.24 1998/08/11 21:39:08 peter Exp $
  3.     This file is part of the Free Pascal Run time library.
  4.     Copyright (c) 1993,97 by the Free Pascal development team
  5.  
  6.     See the File COPYING.FPC, included in this distribution,
  7.     for details about the copyright.
  8.  
  9.     This program is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12.  
  13.  **********************************************************************}
  14.  
  15. {*****************************************************************************
  16.    This File contains the OS independent declarations of the system unit
  17.  
  18.    Possible defines:
  19.    -----------------
  20.    RTLLITE         Create a somewhat smaller RTL
  21.  
  22. *****************************************************************************}
  23.  
  24.  
  25. {****************************************************************************
  26.                    Support for multiple compiler versions
  27. ****************************************************************************}
  28.  
  29. {$i version.inc}
  30.  
  31. {****************************************************************************
  32.                          Global Types and Constants
  33. ****************************************************************************}
  34.  
  35. Type
  36.   Longint  = $80000000..$7fffffff;
  37.   Integer  = -32768..32767;
  38.   shortint = -128..127;
  39.   byte     = 0..255;
  40.   Word     = 0..65535;
  41.  
  42. { at least declare Turbo Pascal real types }
  43. {$ifdef i386}
  44.   {$ifndef VER0_99_5}
  45.     {$ifndef VER0_99_6}
  46.       {$define DEFAULT_EXTENDED}
  47.     {$endif}
  48.   {$endif}
  49.   {$define SUPPORT_EXTENDED}
  50.   {$define SUPPORT_COMP}
  51.   {$define SUPPORT_SINGLE}
  52.   {$define SUPPORT_FIXED}
  53.   Double = real;
  54.   {$ifdef DEFAULT_EXTENDED}
  55.     ValReal = Extended;
  56.   {$else}
  57.     ValReal = Double;
  58.   {$endif}
  59. {$endif}
  60.  
  61. {$ifdef m68k}
  62.    StrLenInt = Integer;
  63.    ValReal = Real;
  64.    {$ifdef USEANSISTRINGS}
  65.       {$error StrLenInt must be a longint if ansi strings are used}
  66.    {$endif}
  67. {$endif}
  68.  
  69. {$ifdef i386}
  70.    StrLenInt = LongInt;
  71. {$endif}
  72. { some type aliases }
  73.   dword    = cardinal;
  74.   longword = cardinal;
  75.  
  76. { Zero - terminated strings }
  77.   PChar  = ^Char;
  78.   PPChar = ^PChar;
  79.  
  80. { procedure type }
  81.   TProcedure = Procedure;
  82.  
  83. const
  84. { max. values for longint and int}
  85.   maxLongint = $7fffffff;
  86.   maxint = 32767;
  87.  
  88. { Compatibility With  TP }
  89. {$ifdef i386}
  90.   Test8086 : byte = 2;       { Always i386 or newer }
  91.   Test8087 : byte = 3;       { Always 387 or newer. Emulated if needed. }
  92. {$endif i386}
  93. {$ifdef m68k}
  94.   Test68000 : byte = 0;      { Must be determined at startup for both }
  95.   Test68881 : byte = 0;
  96. {$endif}
  97.  
  98. { max level in dumping on error }
  99.   Max_Frame_Dump : Word = 8;
  100. { Exit Procedure handling consts and types  }
  101.   ExitProc : pointer=nil;
  102.   Erroraddr: pointer = nil;
  103.   Errorcode: Word    = 0;
  104.  
  105. { file input modes }
  106.   fmClosed = $D7B0;
  107.   fmInput  = $D7B1;
  108.   fmOutput = $D7B2;
  109.   fmInOut  = $D7B3;
  110.   fmAppend = $D7B4;
  111.   Filemode : byte = 2;
  112.  
  113. Type TErrorProc = Procedure (ErrNo : Longint; Address : Pointer);
  114.  
  115. var
  116. { Standard In- and Output }
  117.   Output,
  118.   Input,
  119.   StdErr      : Text;
  120.   ExitCode,
  121.   InOutRes    : Word;
  122.   StackBottom,
  123.   LowestStack,
  124.   RandSeed    : Longint;
  125.  
  126. Const
  127.   ErrorProc   : Pointer = nil;
  128.  
  129. {****************************************************************************
  130.                         Processor specific routines
  131. ****************************************************************************}
  132.  
  133. Procedure Move(Var source,dest;count:Longint);
  134. Procedure FillChar(Var x;count:Longint;Value:Char);
  135. Procedure FillChar(Var x;count:Longint;Value:byte);
  136. {$ifndef RTLLITE}
  137. Procedure FillWord(Var x;count:Longint;Value:Word);
  138. {$endif RTLLITE}
  139.  
  140. {****************************************************************************
  141.                                                            Math Routines
  142. ****************************************************************************}
  143.  
  144. {$ifndef RTLLITE}
  145. Function  lo(w:Word):byte;
  146. Function  lo(l:Longint):Word;
  147. Function  lo(i:Integer):byte;
  148. Function  lo(B: Byte):Byte;
  149. Function  hi(w:Word):byte;
  150. Function  hi(i:Integer):byte;
  151. Function  hi(l:Longint):Word;
  152. Function  Hi(B : Byte): byte;
  153. Function  Swap (X:Word):Word;
  154. Function  Swap (X:Integer):Integer;
  155. Function  Swap (X:Cardinal):Cardinal;
  156. Function  Swap (X:Longint):Longint;
  157.  
  158. {$ifdef VER0_99_5}
  159. Procedure Inc(Var i:cardinal);
  160. Procedure Inc(Var i:Longint);
  161. Procedure Inc(Var i:Integer);
  162. Procedure Inc(Var i:Word);
  163. Procedure Inc(Var i:shortint);
  164. Procedure Inc(Var i:byte);
  165. Procedure Inc(Var c:Char);
  166. Procedure Inc(Var p:PChar);
  167. Procedure Dec(Var i:cardinal);
  168. Procedure Dec(Var i:Longint);
  169. Procedure Dec(Var i:Integer);
  170. Procedure Dec(Var i:Word);
  171. Procedure Dec(Var i:shortint);
  172. Procedure Dec(Var i:byte);
  173. Procedure Dec(Var c:Char);
  174. Procedure Dec(Var p:PChar);
  175. Procedure Dec(Var i:cardinal;a:Longint);
  176. Procedure Inc(Var i:cardinal;a:Longint);
  177. Procedure Dec(Var i:Longint;a:Longint);
  178. Procedure Inc(Var i:Longint;a:Longint);
  179. Procedure Dec(Var i:Word;a:Longint);
  180. Procedure Inc(Var i:Word;a:Longint);
  181. Procedure Dec(Var i:Integer;a:Longint);
  182. Procedure Inc(Var i:Integer;a:Longint);
  183. Procedure Dec(Var i:byte;a:Longint);
  184. Procedure Inc(Var i:byte;a:Longint);
  185. Procedure Dec(Var i:shortint;a:Longint);
  186. Procedure Inc(Var i:shortint;a:Longint);
  187. Procedure Dec(Var c:Char;a:Longint);
  188. Procedure Inc(Var c:Char;a:Longint);
  189. Procedure Dec(Var p:PChar;a:Longint);
  190. Procedure Inc(Var p:PChar;a:Longint);
  191. {$endif VER0_99_5}
  192.  
  193. {$endif RTLLITE}
  194. Function Chr(b:byte):Char;
  195. Function Length(s:string):byte;
  196.  
  197. Function  Random(l:Longint):Longint;
  198. Function  Random:real;
  199. Procedure Randomize;
  200.  
  201. Function abs(l:Longint):Longint;
  202. Function sqr(l:Longint):Longint;
  203. Function odd(l:Longint):Boolean;
  204. { float mathe routines }
  205. {$I mathh.inc}
  206.  
  207.  
  208. {****************************************************************************
  209.                                                          Memory management
  210. ****************************************************************************}
  211.  
  212. Procedure getmem(Var p:pointer;Size:Longint);
  213. Procedure freemem(Var p:pointer;Size:Longint);
  214. Function  memavail:Longint;
  215. Function  maxavail:Longint;
  216.  
  217. {$ifndef RTLLITE}
  218. Function  ptr(sel,off:Longint):pointer;
  219. Function  Addr (Var X):pointer;
  220. Function  Cseg:Word;
  221. Function  Dseg:Word;
  222. Function  Sseg:Word;
  223. {$endif RTLLITE}
  224.  
  225. {****************************************************************************
  226.                                                           PChar Handling
  227. ****************************************************************************}
  228.  
  229. function strpas(p:pchar):string;
  230. function strlen(p:pchar):longint;
  231.  
  232.  
  233. Function  Copy(const s:string;index:StrLenInt;count:StrLenInt):string;
  234. Procedure Delete(Var s:string;index:StrLenInt;count:StrLenInt);
  235. Procedure Insert(const source:string;Var s:string;index:StrLenInt);
  236. Function  Pos(const substr:string;const s:string):byte;
  237. Function  Pos(C:Char;const s:string):byte;
  238. Function  upCase(c:Char):Char;
  239. Function  upCase(const s:string):string;
  240. {$ifndef RTLLITE}
  241. Function  lowerCase(c:Char):Char;
  242. Function  lowerCase(const s:string):string;
  243. Function  hexStr(Val:Longint;cnt:byte):string;
  244. Function  binStr(Val:Longint;cnt:byte):string;
  245. {$endif RTLLITE}
  246. Function  Space(b:byte):string;
  247. Procedure Val(const s:string;Var l:Longint;Var code:Word);
  248. Procedure Val(const s:string;Var l:Longint;Var code:Integer);
  249. Procedure Val(const s:string;Var l:Longint);
  250. Procedure Val(const s:string;Var b:byte;Var code:Word);
  251. Procedure Val(const s:string;Var b:byte;Var code:Integer);
  252. Procedure Val(const s:string;Var b:byte);
  253. Procedure Val(const s:string;Var b:shortint;Var code:Word);
  254. Procedure Val(const s:string;Var b:shortint;Var code:Integer);
  255. Procedure Val(const s:string;Var b:shortint);
  256. Procedure Val(const s:string;Var b:Word;Var code:Word);
  257. Procedure Val(const s:string;Var b:Word;Var code:Integer);
  258. Procedure Val(const s:string;Var b:Word);
  259. Procedure Val(const s:string;Var b:Integer;Var code:Word);
  260. Procedure Val(const s:string;Var b:Integer;Var code:Integer);
  261. Procedure Val(const s:string;Var b:Integer);
  262. Procedure Val(const s:string;Var v:cardinal;Var code:Word);
  263. Procedure Val(const s:string;Var v:cardinal;Var code:Integer);
  264. Procedure Val(const s:string;Var v:cardinal);
  265. Procedure